Skip to content

Conversation

@phacops
Copy link
Contributor

@phacops phacops commented Nov 24, 2025

This will allow us to return array values stored in attributes_array when fetching a trace. Support to return arrays with containing different types were added to sentry-protos (getsentry/sentry-protos#153).

One caveat right now is clickhouse-driver doesn't support the JSON or Variant column types. The workaround for this right now is to encode as JSON and send the value back to Snuba as a string.

There is a PR opened which adds support but there's not a lot of activity. Perhaps we should fork clickhouse-driver and add support for the JSON type for a mid term solution, then upsrtream the result.

@phacops phacops requested review from a team as code owners November 24, 2025 21:12
Comment on lines 488 to 492
attributes_array = _process_arrays(arrays)
for key, value in attributes_array.items():
add_attribute(k, v)

item = GetTraceResponse.Item(

This comment was marked as outdated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a real bug, was this come across in tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it was due to a late refactor before I commit (rename k/v to key/value) and didn't run the tests in-between.

@phacops
Copy link
Contributor Author

phacops commented Nov 27, 2025

Sentry needed to have some compatibility work done: getsentry/sentry#104063

@phacops phacops requested a review from volokluev November 27, 2025 00:14
Comment on lines +231 to +236
expression=FunctionCall(
"attributes_array",
"toJSONString",
(column("attributes_array"),),
),
),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: FunctionCall is instantiated with 3 positional arguments instead of the expected 2, leading to a TypeError at runtime.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The FunctionCall dataclass is defined with two fields: function_name and parameters. However, the code attempts to instantiate FunctionCall with three positional arguments: "attributes_array", "toJSONString", and (column("attributes_array"),). This mismatch in the number of arguments will lead to a TypeError at runtime when the toJSONString function call is constructed, causing an unexpected server crash for any request querying the attributes_array column.

💡 Suggested Fix

Remove the extraneous first argument "attributes_array" from the FunctionCall constructor. The correct call should be FunctionCall("toJSONString", (column("attributes_array"),),).

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: snuba/web/rpc/v1/endpoint_get_trace.py#L231-L236

Potential issue: The `FunctionCall` dataclass is defined with two fields:
`function_name` and `parameters`. However, the code attempts to instantiate
`FunctionCall` with three positional arguments: `"attributes_array"`, `"toJSONString"`,
and `(column("attributes_array"),)`. This mismatch in the number of arguments will lead
to a `TypeError` at runtime when the `toJSONString` function call is constructed,
causing an unexpected server crash for any request querying the `attributes_array`
column.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3924818

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants